import axios from '../http';
import { Base, ResAId } from '../interface/base';

interface CardType extends Base {
	u_id: number;
	name: string;
	deck: Array<number>;
	public: 1 | 0;
}

interface CardDetailType extends CardType {
	partition: Array<number>;
	linner: {
		[key: string]: Array<number>;
	};
}

type UpdateCardType = Omit<CardDetailType, 'id' | 'u_id'>;

// 牌型列表
export const getCardsList: GetListApi<{ group_id?: number; commond?: 'getbyname' }, CardType> = (params) =>
	axios.get('mjconf/card', { params });

// 牌型详细信息
export const getCardsDetail = (id: number): Promise<CardDetailType> => axios.get(`mjconf/card/${id}`);

// 添加、修改牌型
export const addCards = (data: UpdateCardType): ResAId => axios.post('mjconf/card', data);

// 删除牌型
export const delCards = (id: number) => axios.delete(`mjconf/card/${id}`);
